import 'package:cream_chat_flutter/assets/Icons.dart';
import 'package:cream_chat_flutter/components/HiChip.dart';
import 'package:cream_chat_flutter/configs/Host.dart';
import 'package:cream_chat_flutter/globals/ThemeProvider.dart';
import 'package:cream_chat_flutter/models/dopo/UserBaseInfo.dart';
import 'package:cream_chat_flutter/utils/DataDeal.dart';
import 'package:cream_chat_flutter/utils/HiDate.dart';
import 'package:flutter/material.dart';

Widget getUserBaseInfoItem(ThemeProvider tp, UserBaseInfo info) {
  return Container(
    padding: EdgeInsets.only(
        left: tp.getPagePadding(),
        right: tp.getPagePadding(),
        top: tp.getItemMargin(),
        bottom: tp.getItemMargin()),
    child: Flex(
      direction: Axis.horizontal,
      children: [
        Expanded(
            flex: 1,
            child: Padding(
              padding: EdgeInsets.only(right: 10),
              child: ClipRRect(
                borderRadius: BorderRadius.all(tp.getNmRadius()),
                child: Image.network(getCosFile(info.avatar),
                    width: 80, height: 80, fit: BoxFit.cover),
              ),
            )),
        Expanded(
            flex: 3,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisSize: MainAxisSize.max,
              children: [
                Container(
                    padding: EdgeInsets.only(bottom: 3),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisSize: MainAxisSize.max,
                      children: [
                        tp.EllipsisText(info.nickname, style: TextStyle(fontSize: tp.getLgFont())),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          mainAxisSize: MainAxisSize.min,
                          children: [
                            tp.SmTip(info.currCity),
                            tp.SmText("•"),
                            Text(
                                info.isOnline != 0
                                    ? '在线'
                                    : HiDate.diffCurrent(info.lastActive) +
                                        '在线',
                                style: TextStyle(
                                    fontSize: tp.getSmFont(),
                                    color: info.isOnline != 0
                                        ? Colors.yellow
                                        : Colors.grey))
                          ],
                        )
                      ],
                    )),
                Padding(
                    padding: EdgeInsets.only(bottom: 3),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Padding(
                            padding: EdgeInsets.only(right: 5),
                            child: HiChip(
                                Text("${HiDate.parseAge(info.birthday)}岁",
                                    style: TextStyle(
                                        color: Colors.white, fontSize: 10)),
                                avatar: info.gender == 1
                                    ? getManIcon(width: 10, height: 10)
                                    : getWomanIcon(width: 10, height: 10),
                                color: tp.getGenderColor(info.gender))),
                        info.isAuth == 0
                            ? Container()
                            : HiChip(
                                Text("${info.isAuth != 0 ? "真人" : "未认证"}",
                                    style: TextStyle(
                                        color: tp.getGenderColor(info.gender),
                                        fontSize: 10)),
                                avatar: getAuthedIcon(
                                    width: 10,
                                    height: 10,
                                    color: tp.getGenderColor(info.gender)),
                                color: tp.getGenderColor(info.gender),
                                outline: true)
                      ],
                    )),
                Padding(
                    padding: EdgeInsets.only(bottom: 3),
                    child: Row(
                      children: [
                        Padding(
                            padding: EdgeInsets.only(right: 5),
                            child: getSmTagIcon(width: 14, height: 14)),
                        tp.EllipsisText(
                            DataDeal.isBlack(info.tags)
                                ? "暂无标签"
                                : info.tags.replaceAll("|", "•"),
                            style: TextStyle(
                                fontSize: 12,
                                color: tp.getGenderColor(info.gender)))
                      ],
                    )),
                tp.EllipsisText(
                    DataDeal.isBlack(info.motto)
                        ? "该用户很懒，啥都没留下..."
                        : info.motto,
                    style: TextStyle(fontSize: 14, color: Colors.grey))
              ],
            ))
      ],
    ),
  );
}
